<template>
    <div class="page">
        <el-form :inline="true">
            <el-form-item>
                <el-button icon="el-icon-edit" type="primary" @click="edit">编辑比例</el-button>
            </el-form-item>
        </el-form>
        <!-- <span>线下动态比例</span> -->
        <el-table :data="list" border>
            <el-table-column prop="id" label="ID"></el-table-column>
            <el-table-column prop="agentWithdrawalRatio" label="区域代理提现手续费比例"></el-table-column>
            <el-table-column prop="blendRatio" label="商家支付gtfy/szx比例"></el-table-column>
            <el-table-column prop="cashRatio" label="商家支付现金比例"></el-table-column>
            <el-table-column prop="integralRatio" label="释放积分比例"></el-table-column>
            <el-table-column prop="interpolationRatio" label="间推比例"></el-table-column>
            <el-table-column prop="maxWithdrawal" label="用户szx最高提现金额"></el-table-column>
            <el-table-column prop="recommendedRatio" label="推荐比例"></el-table-column>
            <el-table-column prop="szxRatio" label="释放szx比例"></el-table-column>
            <el-table-column prop="szxWithdrawalRatio" label="用户提现手续费比例"></el-table-column>
        </el-table>

        <!-- 表单 -->
        <el-dialog title="代理新增" :visible.sync="dialogShow">
            <el-form :model="form">
                <el-form-item label="区域代理提现手续费比例" label-width="200px">
                    <el-input v-model="form.agentWithdrawalRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="商家支付gtfy/szx比例" label-width="200px">
                    <el-input v-model="form.blendRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="商家支付现金比例" label-width="200px">
                    <el-input v-model="form.cashRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="释放积分比例" label-width="200px">
                    <el-input v-model="form.integralRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="用户szx最高提现金额" label-width="200px">
                    <el-input v-model="form.maxWithdrawal" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="推荐比例" label-width="200px">
                    <el-input v-model="form.recommendedRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="释放szx比例" label-width="200px">
                    <el-input v-model="form.szxRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="间推比例" label-width="200px">
                    <el-input v-model="form.interpolationRatio" autocomplete="off"></el-input>
                </el-form-item>
                <el-form-item label="用户提现手续费比例" label-width="200px">
                    <el-input v-model="form.szxWithdrawalRatio" autocomplete="off"></el-input>
                </el-form-item>

            </el-form>
            <div slot="footer" class="dialog-footer">
                <el-button @click="dialogShow = false">取 消</el-button>
                <el-button type="primary" @click="submit">确 定</el-button>
            </div>
        </el-dialog>
    </div>
</template>
<script>
import M from "minimatch"
import { dynamicRatioList, dynamicRatioEdit } from "../../../api/ds/newSystem"

export default {
    components: {},
    props: {},
    data() {
        return {
            list: [],
            dialogShow: false,
            form: {
                agentWithdrawalRatio: 0,
                blendRatio: 0,
                cashRatio: 0,
                integralRatio: 0,
                maxWithdrawal: 0,
                recommendedRatio: 0,
                szxRatio: 0,
                agentWithdrawalRatio: 0,
                szxWithdrawalRatio: 0
            }
        }
    },
    computed: {},
    watch: {},
    created() {
        this.getData()
    },
    methods: {
        async getData() {
            let res = await dynamicRatioList()
            console.log('%c [ res ]-29', 'font-size:13px; background:#333333; color:#f3f3f3;', res)
            if (res.code === 200) {
                console.log(res)
                this.list = res.rows
            }
        },
        edit() {
            this.dialogShow = true
            // 取值
            this.form = this.list[0]
        },
        async submit() {
            console.log(this.form)
            let res = await dynamicRatioEdit(this.form)
            if (res.code === 200) {
                this.$notify({
                    title: '提示',
                    message: res.msg,
                    duration: 0,
                    type: 'success'
                })
                this.dialogShow = false
                this.getData()
            }
        }
    },

}
</script>
<style lang='scss' scoped>
.page {
    width: 100%;
    box-sizing: border-box;
    padding: 20px;
    background-color: #ffffff;
}
</style>